package com.three.storemanage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.three.core.entity.Station;
import com.three.storemanage.service.StationService;
import com.three.core.entity.Store;
import com.three.core.vo.R;
import com.three.storemanage.utils.Upload;
import com.three.storemanage.vo.SearchForm;
import com.three.storemanage.vo.StationVo;
import com.three.storemanage.service.StationService;
import com.three.storemanage.utils.Upload;
import com.three.storemanage.vo.SearchForm;
import com.three.storemanage.vo.StationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @FileName: StationController
 * @Description:
 * @Author: GYX
 * @CreateTime: 2025/3/11 16:00
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("/store")
public class StationController {
   @Autowired
   private StationService stationService;



   @PostMapping("/station/selectStationWithStore")
   public R<Page<StationVo>> findStationByCondition(@RequestBody SearchForm searchForm) {
      return stationService.findStationByCondition(searchForm);
   }

   @GetMapping("/station/deleteStationByStation")
   public R deleteStationById(Integer station) {
      return stationService.deleteStationById(station);
   }

   @PostMapping("/station/insertStation")
   public R addStation(@RequestBody Station station) {
      return stationService.addStation(station);
   }


   @PostMapping ("/station/uploadFile")
   public R  upload(@RequestParam("file") MultipartFile myfile){
      String path = Upload.uploadOss(myfile);
      return new R<>(200,"上传成功",path);
   }

   @PostMapping("/station/updateStation")
   public R updateStation(@RequestBody Station station) {
      return stationService.updateStation(station);
   }

   @GetMapping("/feign/selectStoreByUserId")
   public R<List<Store>> selectAllStore(@RequestParam Double userLng,@RequestParam Double userLat,@RequestParam String storeName){
      return stationService.queryAll(userLng, userLat,storeName);
   }

   @GetMapping("/selectStoreByUserId")
   public R<List<Store>> selectStoreByUserId(){
      return stationService.selectStoreByUserId();
   }

   @PostMapping("/station/selectByStoreId")
   public R<List<Station>> selectStationByStoreId(Integer storeId){
      return stationService.selectStationByStoreId(storeId);
   }

   @GetMapping("/feign/selectStoreByUserId2")
   public R<List<Store>> selectAllStore(@RequestParam Double userLng,@RequestParam Double userLat){
      return stationService.queryAll2(userLng, userLat);
   }
}
